package com.amigo.online.provider.user.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Component;

import com.amigo.online.common.core.mybatis.MyMapper;
import com.amigo.online.common.param.dto.user.FollowQueryDto;
import com.amigo.online.provider.user.model.entity.Follow;

@Mapper
@Component
public interface FollowMapper extends MyMapper<Follow> {

    List<Follow> checkFollow(@Param("targetId") Long targetId, @Param("userId") Long userId);

    Integer updateCanceled(Follow follow);

    List<Long> selectFansId(FollowQueryDto dto);

    List<Long> selectConcernId(FollowQueryDto dto); // 分页查询

    List<Long> getFriendsId(Long userId);

    List<Follow> checkFans(@Param("targetId") Long targetId, @Param("userId") Long userId);

    List<Long> findFollowStateByUserIdAndUserIds(@Param("id") Long id, @Param("ids") List<Long> ids);

    /**
     * 查看我的粉丝中 我和某人关系
     * 目标是否是否是我的粉丝
     *
     * @param targetId
     * @param userId
     * @return
     */
    Follow checkFansSingle(@Param("targetId") Long targetId, @Param("userId") Long userId);

    /**
     * 查看我的关注中 我和某人关系
     * 目标是否是否是我的关注的人
     *
     * @param targetId
     * @param userId
     * @return
     */
    Follow checkConcernSingle(@Param("targetId") Long targetId, @Param("userId") Long userId);

    @Select("select user_id from follow_tbl where canceled = 0 and target_user_id = #{userId} ORDER BY created_time desc")
    List<Long> listFindUserFansByUserId(@Param("userId") Long id);

}
